<template>
  <div class="order">
    <van-nav-bar title="我的订单" left-arrow @click-left="$router.push('/user')" />
    <van-tabs v-model="active" sticky>
      <van-tab title="全部"></van-tab>
      <van-tab title="待支付"></van-tab>
      <van-tab title="待发货"></van-tab>
      <van-tab title="待收货"></van-tab>
      <van-tab title="待评价"></van-tab>
    </van-tabs>

    <OrderListItem v-for="item in list" :key="item.coupon_id" :item="item"></OrderListItem>
  </div>
</template>

<script>

import OrderListItem from './components/OrderListItem.vue'
import { getOrder } from '@/api/user'
export default {
  name: 'OrderPage',
  components: {
    OrderListItem
  },
  data () {
    return {

      active: this.$route.query.dataType || 'all',
      page: 1,
      list: [],
      total: 0
    }
  },
  methods: {
    async getOrderData () {
      const res = await getOrder(this.active, this.page)
      console.log(res)
      this.list = res.data.list.data
    }
  },
  created () {
    this.getOrderData()
  }
}
</script>

<style lang="less" scoped>
.order {
  background-color: #fafafa;
}
.van-tabs {
  position: sticky;
  top: 0;
}
</style>
